$(function() {

	$('#huodg9').datagrid({
		//请求地址
	    url:'../check/getcheckNotarizeApply',
	    columns:[[
	    	{field:'',title:'',checkbox:true},
			{field:'notarizeId',title:'编号',width:'8%'},
			{field:'applyId',title:'申请编号', width:'8%',
				formatter: function(value,row,index){
				if (row.checkAffairApply){
					return row.checkAffairApply.applyId;
				} else {
					return "";
				}
			}},
			{field:'affairName',title:'事务类型',width:'8%'},
			{field:'beginTime',title:'开始时间',width:'19%'},
			{field:'endTime',title:'结束日期',width:'19%'},
			{field:'approvalStatus',title:'审批状态', width:'8%'},
			{field:'state',title:'状态',width:'9%',
				formatter : function(value, row, index) {
					if (row.state==='是') {
					var btns = "<a href='#' name='opera1' id='huoedit9' class='easyui-linkbutton'></a>";
					return btns;
					}
				}
			} ] ],
			onLoadSuccess : function() {
				$("a[name='opera1']").linkbutton({
					plain : true,
					iconCls : 'icon-edit',
				});
				$("a[name='opera1']").bind('click',function(){
					var rows = $('#huodg9').datagrid('getSelected');
					   $("#notarizeId").val(rows.notarizeId);
						$("#applyId").val(rows.checkAffairApply.applyId);
						$("#holidayType").val(rows.affairName);
						$("#fileDocuments").src="D:\\1.jpg";
						$("#approvalStatus").val(rows.approvalStatus);
						$("#huodd9").window("open");
				});
				
			},
	    fit:true,
	    fitColumns:true,
	    //隔行变色
	    striped:true,
	    nowrap:true,
	    //显示行号
	    rownumbers:true,
	    //设置单选
	    singleSelect:true,
		toolbar:'#huotb9',
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:2,
		//可选的每页大小
		pageList:[2,5,10,20,50]
	});
});
 function searchname(value){
	 $('#huodg9').datagrid('load','../check/serchcheckNotarizeApply?value='+value);
} 
 
 var editIndex = undefined;
	function onClickCell(index, field){
		if (editIndex != index){
			
		}
	}
	function removeit(){
		if (editIndex == undefined){
			var rows = $('#huodg9').datagrid('getSelections');
			if(rows.length > 0){
				$.messager.confirm('请确认','您确定要删除当前所有选中的项目吗？',function(r){
					if(r){
						var applyIds = [];
						for(var i = 0; i < rows.length; i++){
							applyIds.push(rows[i].applyId)
						}
						var huo_rowData = JSON.stringify(applyIds);
						alert(huo_rowData);
						$.ajax({
							url : "../check/deleteNotarizeApply",
							data : {"jsondata" : huo_rowData},
							success : function(e) {
								if (e == "ok") {
	                               alert("删除成功");
	                               $('#huodg9').datagrid('load');
								}
							}
						});
					}
				 })
				}
		}
		$('#huodg9').datagrid('cancelEdit', editIndex).datagrid('deleteRow', editIndex);
		editIndex = undefined;
	}
